package com.dog.view.controller;

import com.dog.model.Applicant;
import com.dog.service.IApplicantService;
import com.dog.spring.ServiceFactory;
import com.dog.view.beans.ApplicantBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.context.WebApplicationContext;

import javax.annotation.PostConstruct;
import javax.faces.model.SelectItem;

/**
 * User: Kuttubek Aidaraliev
 * Date: 06.04.2010
 * Time: 13:35:27
 */
@Controller
@Scope(value=WebApplicationContext.SCOPE_REQUEST)
public class ApplicantBeanController extends BaseBeanController<IApplicantService, Applicant, ApplicantBean> {

    @Autowired
    private IApplicantService applicantService;

    public ApplicantBeanController(){
    }

    @PostConstruct
    protected void initialized(){
        applicantService = ServiceFactory.getApplicantService();
        setService(applicantService);
    }

    @Override
    public String list() {
        return "applicantList";
    }

    @Override
    protected String form() {
        return "applicant";
    }

    @Override
    protected Applicant newEntity() {
        return new Applicant();  
    }

    @Override
    protected SelectItem createSelectItem(Applicant applicant) {
        return new SelectItem(applicant, applicant.getTitle());
    }

    @Override
    protected String getNameEntity() {
        return "applicantBean";
    }

    @Override
    protected ApplicantBean createEntityBean() {
        return new ApplicantBean();
    }


}
